package com.example.hadoopdemo.mapreduce;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;


/**
 * @author jianwang9@iflytek.com
 * @create 2018-04-02 14:15
 **/
public class MapreduceReducer extends Reducer<Text,IntWritable,Text,IntWritable> {

    @Override
    protected void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
        int maxvlue = Integer.MIN_VALUE;

        for (IntWritable value : values) {
            maxvlue = Math.max(maxvlue,value.get());
        }

        context.write(key,new IntWritable(maxvlue));
    }
}
